<?php

use Faker\Generator as Faker;
use App\Models\Product;

$factory->define(App\Models\Prize::class, function (Faker $faker) {
    $sentence = $faker->sentence();
    $remark = $faker->sentence();
    // 随机取一个月以内的时间
    $end = $faker->dateTimeThisMonth();
    // 传参为生成最大时间不超过，创建时间永远比更改时间要早
    $begin = $faker->dateTimeThisMonth($end);

    $product_ids=Product::all()->pluck('id');

    return [
        'status' => $faker->randomElement($array = array (0,1,2)),
        'quantity' => $faker->numberBetween($min = 10, $max = 500),
        'user_redeeming_quantity' => $faker->numberBetween($min = 1, $max = 5),
        'accumulate_point' => $faker->numberBetween($min = 100, $max = 500),
        'shelves_begin' => $begin,
        'shelves_end' => $end,
        'redeeming_begin' => $begin,
        'redeeming_end' => $end,
        'redeemed_begin' => $begin,
        'redeemed_end' => $end,
        'product_id' => $faker->randomElement($product_ids),
        'created_at' => $begin,
        'updated_at' => $end,
    ];
});
